<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <script>
      async function getResponse(url) {
        const resp = await fetch(url, {
          method: "GET",
          headers: { "Content-Type": "application/json" },
        });

        const reader = resp.body.getReader();
        while (true) {
          const textDecoder = new TextDecoder();
          const { value, done } = await reader.read();
          if (done) {
            break;
          }

          const txt = textDecoder.decode(value);
          console.log(txt);
        }
      }

      getResponse("http://127.0.0.1:3000/stream");
    </script>
  </head>
  <body></body>
</html>
